
export default ({
    namespaced:true,
    state: {
         // 提示
         NoticeState:false,
         NoticeInfo:{ message:"",type:"",title:""},
         timer:null,
         
       

         //等待
         WaitState:false,
         WaitInfo:null,

         //导航
         NavigationState:false,
         NavigationBackColor:false,
         NavigationFlag:true, //是否执行设置导航

  

         //通知
         InformData:[],

          //输出
          Output:[]
         
    },
    getters: {},
    mutations: {
        
        // 设置导航
        SETNAVIGATION(state,[NavigationState,NavigationBackColor]){
            if(! state.NavigationFlag) return
           state.NavigationState=NavigationState
           state.NavigationBackColor=NavigationBackColor

        },
        //设置flag
        SETNAVIGATIONFLAG:(state,flag)=> state.NavigationFlag= flag ,


        // 开启提示
       NOTICEON:(state,data)=>{
           state.NoticeInfo=data
           state.NoticeState=true
       },
       // 关闭提示
       NOTICEDOWN:(state)=>{
           state.NoticeInfo={ message:"",type:"",title:""}
           state.NoticeState=false
       },
       
        //增加通知
        INFOEMADD:(state,data) =>{
           
     
            if(data.classify){ //对于同一种分类的 把之前正在展示的收回
                state.InformData.forEach( (element,index )=> {
                    if(element.classify && element.classify == data.classify) {
                        element.isShow = false
                    }
                });
            }
            state.InformData.unshift(data)

            if(state.timer) clearTimeout(state.timer)
            state.timer = setTimeout(() => {
                 state.InformData.filter(item => item.isShow == false)
                 clearTimeout(state.timer)
            }, 3000);

        },

        //减少通知
        INFOEMDELETE:(state,id) =>{
            let index=state.InformData.findIndex(item =>item.id==id)
            state.InformData.splice(index,1)
        },
        
      
         

      
        //开启等待
        WAITON:(state,data)=> {
            state.WaitState=true
            state.WaitInfo=data
        },

        //关闭等待
        WAITDOWN:(state)=> {
            state.WaitState=false
            state.WaitInfo=null
        }
       
    },
})

